package com.spic.business.vehicle.controller;

import com.spic.business.vehicle.domain.VehicleManagementDirty;
import com.spic.business.vehicle.service.IVehicleManagementDirtyService;
import com.spic.common.core.web.controller.BaseController;
import com.spic.common.core.web.domain.AjaxResult;
import com.spic.common.core.web.page.TableDataInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 车辆脏数据Controller
 * 
 * @author 赵祥
 * @date 2022-11-24
 */
@RestController
@RequestMapping("/vehicle/dirty")
public class VehicleManagementDirtyController extends BaseController
{
    @Autowired
    private IVehicleManagementDirtyService vehicleManagementDirtyService;

    /**
     * 查询车辆脏数据列表
     */
    @GetMapping("/list")
    public TableDataInfo list(VehicleManagementDirty vehicleManagementDirty)
    {
        startPage();
        List<VehicleManagementDirty> list = vehicleManagementDirtyService.selectVehicleManagementDirtyList(vehicleManagementDirty);
        return getDataTable(list);
    }


    /**
     * 获取车辆脏数据详细信息
     */
    @GetMapping(value = "/{clientid}")
    public AjaxResult getInfo(@PathVariable("clientid") Long clientid)
    {
        return AjaxResult.success(vehicleManagementDirtyService.selectVehicleManagementDirtyByClientid(clientid));
    }

    /**
     * 新增车辆脏数据
     */
    @PostMapping
    public AjaxResult add(@RequestBody VehicleManagementDirty vehicleManagementDirty)
    {
        return toAjax(vehicleManagementDirtyService.insertVehicleManagementDirty(vehicleManagementDirty));
    }

    /**
     * 修改车辆脏数据
     */
    @PutMapping
    public AjaxResult edit(@RequestBody VehicleManagementDirty vehicleManagementDirty)
    {
        return toAjax(vehicleManagementDirtyService.updateVehicleManagementDirty(vehicleManagementDirty));
    }

    /**
     * 删除车辆脏数据
     */
	@DeleteMapping("/{clientids}")
    public AjaxResult remove(@PathVariable Long[] clientids)
    {
        return toAjax(vehicleManagementDirtyService.deleteVehicleManagementDirtyByClientids(clientids));
    }

    @GetMapping("statistics")
    public AjaxResult statistics() {
        Map<String, Integer> map = vehicleManagementDirtyService.statistics();
        return AjaxResult.success(map);
    }
}
